/**
 * 消息阶段类型，普通
 */
const MESSAGE_STAGE_TYPE_NORMAL = 1;
/**
 * 消息阶段类型，任务已完成
 */
const MESSAGE_STAGE_TYPE_JOB_ISFINISHED = 2;
//获取当前网站的端口
function getPort() {
    const port = window.location.port;
    if (port) return port;
    else if (window.location.protocol === "https:") return 443;
    return 80;
}
/**
 * 获取站点名称
 * @returns 站点名称/ip地址
 */
function getHostName(){
    const hostName=window.location.hostname;
    if (hostName){
        return hostName;
    }
    else{
        return "localhost";
    }
}

function  getLoginToken(){
    return localStorage.getItem("token");
}

function getWebsocketUri(){
  return "wss://"+getHostName()+":" + getPort() + "/websocket";
}

/**
 * 显示消息
 * @param title 标题
 * @param message 消息内容
 * @param type 类型 success/default/primary/info/warning/danger/dark
 */
function showMessage(title, message, type) {
    $.alert({
        title: title,
        content: message,
        type: type === 'success' ? 'green' : 'red',
        backgroundDismiss: true,
        animation: 'opacity',
        closeAnimation: 'opacity',
        animateFromElement: false,
        boxWidth: '400px',
        useBootstrap: false,
        buttons: {
            ok: {
                text: '确定',
                btnClass: type === 'success' ? 'btn-success' : 'btn-danger',
                action: function () {
                    if (type === 'success') {
                        $('#jarTable').bootstrapTable('refresh');
                    }
                }
            }
        }
    });
}